#ifndef SMTGUI_GLOBAL_H
#define SMTGUI_GLOBAL_H

#if defined(SMT_GUI_LIBRARY_COMPILING)
#  define SMT_GUI_SHARED_EXPORT __declspec(dllexport)
#else
#  define SMT_GUI_SHARED_EXPORT __declspec(dllimport)
#endif

#include <QObject>
#include <QDoubleSpinBox>
#include <QComboBox>
#include <QMouseEvent>
#include <QResizeEvent>
#include <QToolButton>
#include <QLabel>
#include <QListWidget>
#include <QListView>
#include <QTimer>
#include <QColor>
#include <QScrollArea>
#include <QDropEvent>

class SMTImageWnd;
class SMTMessageLabel;
class SMTImage;
class SMTShape;
class SMTShapeArray;
class SMTPoint;
class StatusBarFormData;
class CSMTItemType;
class CSMTItem;
class SMTFont;
class SMTRangeImage;
class SMTPointCloud;
class SMTVector3d;

#define SMT_BTN_LOADING    0x80000000
#define SMT_BTN_ZOOMINIMG  0x40000000
#define SMT_BTN_ZOOMOUTIMG 0x20000000
#define SMT_BTN_FITIMG     0x10000000
#define SMT_BTN_ORIGINIMG  0x08000000
#define SMT_BTN_DRAWRECT   0x04000000
#define SMT_BTN_DRAWRECT2  0x00040000
#define SMT_BTN_DRAWANNULAR 0x02000000
#define SMT_BTN_DRAWELLIPSE 0x01000000
#define SMT_BTN_DRAWCIRCLE 0x00020000
#define SMT_BTN_DRAWLINE   0x00800000
#define SMT_BTN_DRAWPOLYGON 0x00400000
#define SMT_BTN_DRAWANYLINE 0x00200000
#define SMT_BTN_DRAWPOINT  0x00100000
#define SMT_BTN_DRAWANYCLOSELINE 0x00080000
#define SMT_BTN_ALL        (SMT_BTN_LOADING | SMT_BTN_ZOOMINIMG | SMT_BTN_ZOOMOUTIMG \
                           | SMT_BTN_FITIMG | SMT_BTN_ORIGINIMG | SMT_BTN_DRAWRECT \
                           | SMT_BTN_DRAWRECT2 | SMT_BTN_DRAWANNULAR | SMT_BTN_DRAWELLIPSE \
                           | SMT_BTN_DRAWCIRCLE | SMT_BTN_DRAWLINE | SMT_BTN_DRAWPOLYGON \
                           | SMT_BTN_DRAWANYLINE | SMT_BTN_DRAWPOINT | SMT_BTN_DRAWANYCLOSELINE)

#define		SMT_3D_BTN_ALL                       0x00000001L
#define		SMT_3D_BTN_IMPORT                    0x80000000L
#define		SMT_3D_BTN_EXPORT                    0x40000000L
#define		SMT_3D_BTN_DRAWPOINTS				 0x20000000L
#define		SMT_3D_BTN_DRAWEDGES				 0x10000000L
#define		SMT_3D_BTN_DRAWFACES				 0x08000000L
#define		SMT_3D_BTN_ADJUSTSIZE				 0x04000000L
#define		SMT_3D_BTN_TOGGLELIGHT				 0x00040000L
#define		SMT_3D_BTN_DRAWAXIS 				 0x02000000L
#define		SMT_3D_BTN_DRAWVNORMAL				 0x01000000L
#define		SMT_3D_BTN_DRAWFNORMAL				 0x00020000L
#define		SMT_3D_BTN_CHANGEBGCOLOR			 0x00800000L
#define		SMT_3D_BTN_CHANGEFACECOLOR			 0x00400000L
#define		SMT_3D_BTN_CHANGEEDGECOLOR			 0x00200000L
#define		SMT_3D_BTN_CHANGEVERTICECOLOR		 0x00100000L
#define		SMT_3D_BTN_CHANGEPERSPECTIVE		 0x00010000L
#define		SMT_3D_BTN_CLEAR					 0x00008000L

enum ItemMode
{
    IconOnly,
    TextOnly,
    TextBesideIcon,
    TextUnderIcon
};

class SMT_GUI_SHARED_EXPORT SMTSignalLight : public QLabel
{
    Q_OBJECT
public:
    explicit SMTSignalLight(QWidget *parent = nullptr);

public:
    void setSignalState(bool bSignalstate);
    bool getSignalState() const;

    void setSignalOnColor(QColor colorSignalOn);
    QColor getSignalOnColor() const;

    void setSignalOffColor(QColor colorSignalOff);
    QColor getSignalOffColor() const;

    void setSignalOnStr(QString strSignalOn);
    QString getSignalOnStr() const;

    void setSignalOffStr(QString strSignalOff);
    QString getSignalOffStr() const;

protected:
    bool m_bSignalState;
    QColor mColorSignalOn;
    QColor mColorSignalOff;
    QString mStrSignalOn;
    QString mStrSignalOff;
    static QColor DarkenColor(const QColor& col);

    void paintEvent(QPaintEvent *event);
};


class SMT_GUI_SHARED_EXPORT SMTSpinBox : public QDoubleSpinBox
{
    Q_OBJECT

public:
    explicit SMTSpinBox(QWidget *parent = nullptr);
    ~SMTSpinBox();

public slots:
    void setValue(double val);

public:
    double maximum() const;
    double minimum() const;
    void setMaximum(double max);
    void setMinimum(double min);
    void setDecimals(int prec);
    double value() const;
    void setSingleStep(double val);

protected:
    bool eventFilter(QObject *obj, QEvent *event);
    void stepBy(int steps);
    bool changeValues(bool bAdd);

	void focusInEvent(QFocusEvent *event);
	void focusOutEvent(QFocusEvent *event);
	void wheelEvent(QWheelEvent *event);

private:
    bool getbBySingleStep(const QString &strSingleStep, const QString &strSel, const QString &strTxt, int selStart);
};

class SMT_GUI_SHARED_EXPORT SMTSwitchButton : public QWidget
{
    Q_OBJECT

    //属性的公开目的 qss设置
    Q_PROPERTY(QColor backgroundOnColor READ bgOnColor WRITE setBgOnColor)
    Q_PROPERTY(QColor backgroundOffColor READ bgOffColor WRITE setBgOffColor)
    Q_PROPERTY(QColor sliderOnColor READ sliderOnColor WRITE setSliderOnColor)
    Q_PROPERTY(QColor sliderOffColor READ sliderOffColor WRITE setSliderOffColor)

public:
    explicit SMTSwitchButton(QWidget *parent = 0);
    ~SMTSwitchButton();

public:
    //设置Off状态的背景颜色
    void setBgOffColor(const QColor &bgOffColor);
    QColor bgOffColor() const;

    //设置On状态的背景颜色
    void setBgOnColor(const QColor &bgOnColor);
    QColor bgOnColor() const;

    //设置滑块Off的颜色
    void setSliderOffColor(const QColor &sliderOffColor);
    QColor sliderOffColor() const;

    //设置滑块On的颜色
    void setSliderOnColor(const QColor &sliderOnColor);
    QColor sliderOnColor() const;

    //设置滑块状态
    void setChecked(bool m_checked);

	//滑块状态
	bool isChecked();

	void setEnabled(bool bEnabled);

signals:
    //滑块状态变更
    void checkedChanged(bool m_checked);

protected:
    void mousePressEvent(QMouseEvent *event);
    void resizeEvent(QResizeEvent *event);
    void paintEvent(QPaintEvent *event);
    void drawBg(QPainter *painter);
    void drawSlider(QPainter *painter);
    void drawText(QPainter *painter);
	void drawDisable(QPainter *painter);

private slots:
    void updateValue();

private:
    bool   m_checked;
    QColor m_bgOffColor;
    QColor m_bgOnColor;
    QColor m_sliderOffColor;
    QColor m_sliderOnColor;
    QColor m_textColorOff;
    QColor m_textColorOn;
    QString m_textOff;
    QString m_textOn;
    int m_space;
    int m_rectRadius;
    float m_step;
    float m_startX;
    float m_endX;
    QTimer *m_timer;
};

class DropView;
class SMT_GUI_SHARED_EXPORT SMTComboBox : public QComboBox
{
    Q_OBJECT

public:
    explicit SMTComboBox(QWidget *parent = 0);
    ~SMTComboBox();

    //下拉框中追加项
    void addItem(const QString &text);

    //设置下拉框的项,
    void addItems(const QStringList &texts);

    //设置当前选中的项
    void setCurrentText(QString text);

    //设置当前选中的项，项是否是有效项
    void setCurrentIndex(int index);

    //设置当前常量值
    void setSpinBoxValue(double val);
	double spinBoxValue();

    QString currentText() const;
    int currentIndex() const;

    void setSpinBoxMaximum(double max);
    double spinBoxMaximum() const;

    void setSpinBoxMinimum(double min);
    double spinBoxMinimum() const;

    void setSpinBoxRange(double minimum, double maximum);

    void setSpinBoxDecimals(int prec);
    int  spinboxDecimals();

    void setSpinBoxSingleStep(double val);
    double spinBoxSingleStep() const;

    void clear();

signals:
    void clicked();
    void currentIndexChanged(int index);
	void currentTextChanged(QString text);
    void valueChanged(double value);
	void valueEditingFinished(double value);

protected:
    void resizeEvent(QResizeEvent *e);
    void mousePressEvent(QMouseEvent *e);
    bool eventFilter(QObject *obj, QEvent *event);

private slots:
    void showDropView();
    void currentIndexChanged(int index, QString text);
    void spinBoxValueChanged(QString text);
	void spinBoxEditingFinished();

private:
    DropView* m_dropView;
    QString  m_currentText;
    int      m_currentIndex;
};

class SMT_GUI_SHARED_EXPORT SMTButtonBox : public QWidget
{
    Q_OBJECT

public:
    explicit SMTButtonBox(QWidget *parent = 0);
    ~SMTButtonBox();

public:
    void setButtonStyle(ItemMode style);
    void addButton(QString text);
    void addButton(QString text, QIcon icon);
    void setCurrentIndex(int index);
    int currentIndex();
    QString currentText();
    bool setButtonText(int index, QString text);
    bool setButtonIcon(int index, QIcon icon);
    bool setIconSize(QSize size);
    bool removeButton(int index);
    bool removeButton(QString text);

signals:
    void selectionChanged(int index);

private slots:
    void checkedChange(bool checked);

private:
    QVector<QToolButton* > m_buttons;
    int m_currentIndex;  //当前选中的button
    int m_style;
};

class SMT_GUI_SHARED_EXPORT SMTMultiSelectButtonBox : public QWidget
{
	Q_OBJECT

public:
	explicit SMTMultiSelectButtonBox(QWidget *parent = 0);
	~SMTMultiSelectButtonBox();

public:
	void setButtonStyle(ItemMode style);
	bool setIconSize(QSize size);

	void addButton(QString text);
	void addButton(QString text, QIcon icon);

	bool setButtonText(int index, QString text);
	bool setButtonIcon(int index, QIcon icon);

	bool removeButton(int index);
	bool removeButton(QString text);

	void setSelectStatus(int index, bool bSelected);
	bool getSelectStatus(int index);

signals:
	void statusChanged(int index, bool selected);

	private slots:
	void checkedChange(bool checked);

private:
	QVector<QToolButton* > m_buttons;
	int m_style;
};

class SMT_GUI_SHARED_EXPORT SMTImageView : public QLabel
{
public:
    explicit SMTImageView(QWidget *parent = 0);
    ~SMTImageView();

    //设置需显示图像的完整路径
    void setImageFile(QString filePath);
    QString imageFile();

protected:
    void resizeEvent(QResizeEvent *event);

private:
    void loadImage(int width, int height);

private:
    QString m_filePath;
};

class SMT_GUI_SHARED_EXPORT SMTMessageLabel : public QWidget
{
    Q_OBJECT
public:

    enum messageType
    {
        WARNNING = 0,
        ERRORS,
        TIPS,
        NONE,
    };
    Q_ENUM(messageType)

public:
    explicit SMTMessageLabel(QWidget *parent = 0);
    ~SMTMessageLabel();

    void setAlignment(Qt::Alignment alignment = Qt::AlignLeft | Qt::AlignVCenter);
    void setMessageType(const messageType type);
    void appendText(const QString &text,
                    const QFont &font = QFont(),
                    const QColor &color = Qt::gray,
                    const bool newLine = false);
    void clear();

private:
    QSharedDataPointer<StatusBarFormData> data;
};

class SMT_GUI_SHARED_EXPORT SMTMutiListWidgetItem
{

public:
    explicit SMTMutiListWidgetItem(QString text);
    explicit SMTMutiListWidgetItem();
    ~SMTMutiListWidgetItem();

    void addChild(SMTMutiListWidgetItem* child);
    void addChildren(QList<SMTMutiListWidgetItem *> children);
    QList<SMTMutiListWidgetItem *> children();

    SMTMutiListWidgetItem *parent() const;
    void setParent(SMTMutiListWidgetItem *parent);

    void remove(SMTMutiListWidgetItem* child);
    void removeAll();

    void setText(QString text);
    QString text();

private:
    QString m_text;
    QList<SMTMutiListWidgetItem *> childList;
    SMTMutiListWidgetItem*   m_parent;
};

class SMT_GUI_SHARED_EXPORT SMTMutiListWidget : public QListView
{
    Q_OBJECT

public:
    explicit SMTMutiListWidget(QWidget *parent = 0, int ListNum = 3);
    ~SMTMutiListWidget();

    void addTopItem(SMTMutiListWidgetItem* item);
    void addTopItems(QList<SMTMutiListWidgetItem*> items);

    void removeTopItem(SMTMutiListWidgetItem* item);
    void removeAll();

signals:
    void itemDoubleClicked(SMTMutiListWidgetItem* item);
    void itemEnter(SMTMutiListWidgetItem* item);
    void itemClicked(SMTMutiListWidgetItem* item);

private slots:
    void on_clicked(const QModelIndex &index);
    void on_doubleClicked(const QModelIndex &index);
    void on_entered(const QModelIndex &index);

private:
    int m_ListNum;
    QList<QListView*> m_ListView;
    QList<SMTMutiListWidgetItem*> m_itemList;
    QMap<QString, QList<SMTMutiListWidgetItem*> > m_otherItemMap;
};

class SMT_GUI_SHARED_EXPORT SMTTreeWidget : public QWidget
{
	Q_OBJECT

public:
	explicit SMTTreeWidget(QWidget *parent = nullptr);
	~SMTTreeWidget();

	void resizeEvent(QResizeEvent *event);

	void SetColumns(int cols);
	void SetHorizontalSpacing(int pixels);
	void SetVerticalSpacing(int pixels);
	void SetBoxItemSize(int wdt, int hgt);
	void SetItemCheckable(bool istate);
	void SetItemHasLabel(bool haslab);
	void SetChildItemMode(ItemMode itmd);
	void SetTopItemMode(ItemMode topitmd);
	void SetItemFoldable(bool istate);
	void SetTopQss(QString topqss);
	void SetChildQss(QString chqss);
	void AddToplevelItem(QString name, QIcon icon);
	void RemoveTopLevelItem(int index);
	bool AddSubItem(int indexTop, QString name, QIcon icon);
	bool RemoveSubItem(int indexTop, int indexSub);
	int  getTopCount();
	void ClearAll();

	void ResetWidgets();

signals:
	void sigChildItemChecked(int, int);
	void sigChildItemPressed(int, int);

	public slots:
	void procBoxFoldSig(int topid);
	void procChildItemCheckSig(bool, int, int);

private:
	bool m_haslabel;

	QString m_topqss;
	QString m_childqss;
	int  m_ColsInBox;
	int  m_IdenticalHSpacing;
	int  m_IdenticalVSpacing;
	int  m_BoxItemWidth;
	int  m_BoxItemHeight;
	int  m_AmountWidth;
	int  m_AmountHeight;
	int  m_SliderDistance;
	bool m_IdenticalIsBoxFodable;
	bool m_IdenticalItemCheckable;
	int m_CheckID;
	QList<CSMTItemType*> m_TopItemArray;
	QList<CSMTItem*> m_SubItemSelected;

	ItemMode m_IdenticalItemMode;
	ItemMode m_TopItemMode;

	CSMTItemType *m_pNewestTopItemPoint;
	QScrollArea  *m_pScrollArea;
	QScrollBar   *m_pVerticalBar;
	QWidget      *m_pTopWidget;
};

class SMT_GUI_SHARED_EXPORT SMTImageWnd : public QObject
{
   Q_OBJECT

   public:
	   enum Layer
	   {
		   //2D Layers
		   BackgroundLayer = 0,
		   ActiveLayer,
		   ForegroundLayer,

		   //3D Layers
		   RangeImage,
		   PointCloud,
		   TriangleMesh,
		   Shape3D,
		   ROI3D
	   };

	   enum DisplayType3D
	   {

	   };

	   enum SMT3DPerspective
	   {
		   SMT_3D_GRAPHICS_TOPVIEW = 0,
		   SMT_3D_GRAPHICS_BOTTOMVIEW,
		   SMT_3D_GRAPHICS_FRONTVIEW,
		   SMT_3D_GRAPHICS_BACKVIEW,
		   SMT_3D_GRAPHICS_LEFTVIEW,
		   SMT_3D_GRAPHICS_RIGHTVIEW,
		   SMT_3D_GRAPHICS_OBLIQUEVIEW,
	   };

	   enum WindowMode
	   {
		   Graphics2D = 0,
		   Graphics3D
	   };

       explicit SMTImageWnd(QObject *parent = 0);
       ~SMTImageWnd();

	   void setViewSceneRect(int width, int height, QColor color = QColor(0, 0, 0));//不支持3D
	   //用于标定功能，在背景层显示的标定点，大小不随缩放改变，而是相对于屏幕有固定的比例
	   //double rate 用于设置此比例，须大于0，一般小于1；			bool ind 用于控制功能的开启与关闭。
	   long setPointSizeIndependent(double rate, bool ind = true);//不支持3D
	   long setShapeHoverMode(bool, QColor& penColor = QColor(255,255,0));//不支持3D；2D模式下，当鼠标悬停在ActiveLayer的图形上方时，画笔粗细+1，画笔颜色变为指定颜色
	   bool isShapeHoverMode(QColor* = NULL);//不支持3D

       long setBrush(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha);//目前不支持3D，相关底层接口未开放
       long getBrush(unsigned char *red, unsigned char *green, unsigned char *blue,  unsigned char *alpha);//目前不支持3D，相关底层接口未开放
       long setPen(unsigned char red, unsigned char green, unsigned char blue, unsigned long lineWidth = 0);
       long getPen(unsigned char *red, unsigned char *green, unsigned char *blue, unsigned long *lineWidth);
       long getZoomRatio(double *scaleValue);//2D版本完整支持，3D版本下返回的为x轴缩放比例
	   long getZoomRatio(double *x, double *y, double *z);//用于3D图形控件获取三个维度的缩放比例
	   long setPointSize(int size = 5);//不支持3D
	   long getPointSize(int *size);//不支持3D
	   void setArrowSize(int size = 7);//不支持3D
	   int getArrowSize();//不支持3D
	   long setFont(SMTFont font);//目前不支持3D，相关底层接口未开放
	   long getFont(SMTFont *font);//目前不支持3D，相关底层接口未开放
	   long setLineWidth(float lineWidth = 0);//注意：在setPen中也会设置此值(默认会设置为0)，两者会相互覆盖
	   long getLineWidth(float *lineWidth);

	   //3D
	   void setWindowMode(SMTImageWnd::WindowMode mode = Graphics2D);
	   int  windowMode();
	   long setRunBackground(SMTRangeImage &image);
	   long setRunBackground(SMTPointCloud& image);//仅供3D使用
	   long getBackground(SMTRangeImage *image);//目前仅支持2D, 3D暂不支持，因底层接口未开放
	   long getBackground(SMTPointCloud *pointCloud);//仅供3D使用,目前在3D模式下不具备功能，因底层接口未开放
	   long get3DShape(long id, SMTShape *shape);//2D模式下，会将id对应的2D图形转换为3D类型;3D模式下返回id对应的3D图形
	   //long get3DROI(long id, Sci3DROI *shape);//仅供3D使用
	   long displayRunShape(SMTShape &shape3D);

	   long set3DColorBar(double min, double max, bool visable);//仅3D
	   long set3DBackgroundColor(QColor &color = QColor(0, 0, 0));//仅3D
	   long setProjection(bool orthographic);//仅3D,true-正交投影，false--透视投影
	   long setPerspective(SMT3DPerspective perspective);//仅3D,设置视图
	   long setSamplingRatio(int samplingRatio);//设置深度图采样率，大于0的整数，建议2或3

   public slots:
       //创建图像控件 (类似 parentWndHandle = (long long)ui->label)
       long create(long long parentWndHandle, int left, int top, int right, int bottom);
       long create(long long parentWndHandle);
	   long create(WId id);
       long setParentWnd(long long parentWndHandle);
       long destory();
       long move(int left, int top, int right, int bottom);
       //控制工具栏的按钮的显示状态(类似于：showToolbutton（SMT_BTN_LOADING，false）导入图像按钮不显示)
       long showToolbutton(long index, bool visable);//consider if logical calculation is applicable to JS.
	   void setToolBarEnable(bool enable);//目前仅支持2D，3D暂未开放相关接口
       long showToolbar(bool bVisible);//目前仅支持2D，3D暂未开放相关接口
       bool showStatusbar(bool bVisible);//目前仅支持2D，3D暂未开放相关接口
       bool showScrollbar(bool bVisible);//目前仅支持2D，3D暂未开放相关接口
	   long zoom(double scaleValue);//3D模式下会将三个维度的缩放比例都设置为scaleValue
	   long zoom(double x, double y, double z);//仅供3D使用
	   long zoom(SMTVector3d&pos, double scaleValue);//3D模式下，以指定位置为中心进行缩放,模拟鼠标缩放
       long zoomFitWnd();
       long zoomReset();//目前仅支持2D，3D暂未开放相关接口
       long zoomIn();
       long zoomOut();
       long repaint();//仅供2D使用,3D下暂未提供相关接口
       long screenshot(const char *filePath);//目前仅2D支持
	   long screenshot(SMTImage* image);//目前仅2D支持
	   long screenshotOrigin(const char *filePath);//目前仅2D支持
	   long screenshotOrigin(SMTImage* image);//目前仅2D支持
	   void setViewRect(int x, int y, int w, int h);//仅2D支持

       long removeShape(long long id);
       long visibleShape(long long id, bool visible = true);//目前仅2D支持
	   long moveAbleShape(long long id, bool moveAble = true);//目前仅2D支持
	   void setShapeColor(long long id, QColor color, unsigned long lineWidth = 0);//改变shape的颜色,目前仅2D支持
	   void changeActiveLayerShapeSize(long long id, SMTShape& shape); //改变shape的大小，前提是传入的shape类型，跟之前一样，目前仅2D支持
	   void getImageWndSize(long &width, long &height); //获取图像控件的大小， 目前仅2D支持

	   void setShapeToolTip(long long id, QString toolTip);//设置shape的Tip
	   void setToolTipStyle(QFont font, QColor color);

       long clear();
       long clearBackground();
	   long clearLayer(SMTImageWnd::Layer layerIndex);
	   long clear3DLayer(SMTImageWnd::DisplayType3D);

       //显示图像
       long setBackground(SMTImage &image);
       long getBackground(SMTImage *image);//目前仅2D支持, 3D还未开放相关接口
	   long setBackground(SMTRangeImage &image);

       //显示各种Shape
	   long displayShape(SMTShape &shape, SMTImageWnd::Layer layerIndex = BackgroundLayer);//第二个参数仅用于2D模式
	   long getShape(long long id, SMTShape *shape);

	   QList<long> displayShapes(SMTShapeArray& shapes, SMTImageWnd::Layer layerIndex = BackgroundLayer);

	   //运行调用
	   void setRunBackground(SMTImage &image);
	   QList<long long> displayRunShapes(SMTShapeArray& shapes);
	   void removeRunShapes(QList<long long>& shapesID);

	   //以下仅2D支持
	   long resetDraw();
       long drawPoint();
       long drawLine();
       long drawRect();
       long drawRotateRect();
       long drawEllipse();
       long drawCircle();
       long drawPolygon();
       long drawIrregular();
       long drawTorus();
       long drawText();
       long drawArrowLine();
	   long drawClosedAnyLine();
	   long drawMatrix();

	   void SetFloatFlag(bool isFloat);
	   bool isFloat();
	   void SetFloatAreaVisible(bool visible = false);
	   void SetIntoBtnVisible(bool visible = false);
	   void SetFloatTipText(QString text);

	   void removeShapeList(QList<long> idList);
	   QList<long> getShapeIDS(SMTImageWnd::Layer layerIndex = ActiveLayer);

	   void setNum(QString numStr);
	   void setNumVisible(bool visible = false);

	   void setActiveLayerMoveable(bool bMove);
	   bool activeLayerMoveable();

	   void setRegionZValue(int iValue);
	   int  getRegionZValue();

	   void lock();
	   void unlock();

	   long drawTemplateRect();
	   long drawTemplateRotateRect();
	   long drawTemplateEllipse();
	   long drawTemplateCircle();
	   long drawTemplatePolygon();

   signals:
       void mouseMove(double pointX, double pointY);
       void mouseButtonDown(long indexButton);
       void mouseButtonUp(long indexButton);
       void shapeResized(long id);
       void shapeMoved(long id);
       void shapeClicked(long id);
       void buttonClicked(long indexButton);
	   void templateShapeClicked(long id);
	   void rightShapeClicked(long id);

	   void floatBtnClicked(bool);
	   void intoBtnClicked(bool);
	   void mouseDoubleClick();
	   void mouseClicked(double pointX, double pointY);

//调用者像图像控件发信号
	   void selectShape(long long id);
	   void setContionusDrawMode(bool bContionusMode);

private:
	long convertShape3Dto2D(const SMTShape &shape3D, SMTShape *shape);
	long convertShape2Dto3D(const SMTShape &shape, SMTShape* shape3D);
    void *data;
};

class SMT_GUI_SHARED_EXPORT SMTMutiListView : public QListView
{
	Q_OBJECT

public:
	typedef struct
	{
		long long id;
		bool    enable;
		QString leftIconFile;
		QString text;
		QString rightIconFile;
	} ItemData;

	explicit SMTMutiListView(QWidget *parent = 0);
	~SMTMutiListView();

	long long getId(int row);
	void addItem(ItemData &itemData);
	void addItems(QList<ItemData> &labels);
	void replaceItem(int row, ItemData &itemData);
	ItemData getItem(int row);

	void leftIconVisible(bool isVisible = true);
	void rightIconVisible(bool isVisible = true);
	void ItemIsSlidable(bool slidable = true);
	void delBtnVisible(bool isVisible = true);
	void nextPageBtnVisible(bool isVisible = true);
	void setDragEnable(bool enable = true);
	void delRow(int row);
	void setSelectIndex(int index);
	QList<int> currentSelectIndex();

signals:
	void delClicked(int row);
	void delClicked(int row, QString text);
	void clicked(int row);
	void nextClicked(int row);
	void checkChanged(int row, bool enable);
	void indexChanged(int beforeIndex, int afterIndex);
	void delClicked(int row, long long id);
	void clicked(int row, long long id);

protected:
	void dropEvent(QDropEvent * event);

	private slots:
	void deleteRow(int row);
	void clickedRow(int row);
	void pressed(QModelIndex index);
	void changeValue(int row, bool checked);

private:
	int m_moveRow;
};

class SMT_GUI_SHARED_EXPORT SMTMutiSelectListView : public QListView
{
	Q_OBJECT

public:

	enum CheckMode
	{
		SingleSelected = 0,
		MutiSelected
	};

	explicit SMTMutiSelectListView(QWidget *parent = 0);
	~SMTMutiSelectListView();

	void setCheckMode(CheckMode isCheckMode);
	void setColumnCount(int columns = 1);
	void setChecked(int row, bool checked);
	bool isChecked(int row);
	void setText(int row, int col, QString text);
	QString getText(int row, int col);
	void ItemIsSlidable(bool slidable = true);
	void delBtnVisible(bool isVisible = true);
	void setDragEnable(bool enable = true);
	void delRow(int row);

signals:
	void delClicked(int row);
	void clicked(int row);
	void checkChanged(int row, bool checked);
	void indexChanged(int beforeIndex, int afterIndex);

protected:
	void dropEvent(QDropEvent * event);
	void dragEnterEvent(QDragEnterEvent *event);

	private slots:
	void deleteRow(int row);
	void clickedRow(int row);
	void pressed(QModelIndex index);
	void changeValue(int row, bool checked);

private:
	int m_moveRow;
	int m_colums;
};

#endif // SMTGUI_GLOBAL_H
